<?php
namespace app\enum;
abstract class UrlEnum
{
    /**
     * @var array|string[] 素材服务链接列表
     */
    public const MATERIAL_URL = [];

    /**
     * @var array|string[] 财务服务链接列表
     */
    public const FINANCE_URL = [];

    /**
     * @var array|string[] 账户服务链接列表
     */
    public const ADVERTISER_URL = [];

    public const DSP_URL = [];

    public static string $financeName = '';

    /**
     * 获取服务名.
     * @param string $node 节点名
     */
    public static function getServiceName(string $node = ''): string
    {
        $name = '';
        if ($node) {
            switch ($node) {
                case 'finance':
                case 'material':
                case 'advertiser':
                case 'dsp':
                    $name = static::$financeName;
                    break;
                case 'ad':
                    $name = static::$apiName;
                    break;
                case 'dingTalk':
                case 'feishu':
                case 'qywx':
                    $name = static::$serviceName;
                    break;
                case 'dingTalkApi':
                    $name = static::$apiServiceName;
                    break;
                default:
                    break;
            }
        }

        return $name;
    }

    /**
     * 获取服务链接.
     *
     * @param string $node 节点
     * @param string $key 链接key
     * @return mixed|string
     */
    public static function getServiceUrl(string $node = '', string $key = '')
    {
        $url = '';
        if ($node && $key) {
            switch ($node) {
                case 'finance':
                    $url = static::FINANCE_URL[$key] ?? '';
                    break;
                case 'material':
                    $url = static::MATERIAL_URL[$key] ?? '';
                    break;
                case 'advertiser':
                    $url = static::ADVERTISER_URL[$key] ?? '';
                    break;
                case 'token':
                    $url = static::TOKEN_URL[$key] ?? '';
                    break;
                case 'ad':
                    $url = static::AD_URL[$key] ?? '';
                    break;
                case 'msg':
                    $url = static::MSG_URL[$key] ?? '';
                    break;
                case 'dsp':
                    $url = static::DSP_URL[$key] ?? '';
                    break;
                default:
                    break;
            }
        }
        return $url;
    }
}
